Skip to content

[Bernard Wan De Yuan] iP#461

Open
bernardwan wants to merge 40 commits into
nus-cs2103-AY2122S1:masterfrom
bernardwan:master
Open

[Bernard Wan De Yuan] iP#461
bernardwan wants to merge 40 commits into
nus-cs2103-AY2122S1:masterfrom
bernardwan:master

Conversation

@bernardwan

@bernardwan bernardwan commented Aug 25, 2021

Copy link
Copy Markdown

DUKE

“Your mind is for having ideas, not holding them.” – David Allen (source)

Hi this is my Duke program! It's

  • Fun 👍
  • Easy to use
  • text-based

Steps to use:

  1. Download from here
  2. Run
  3. Use!

Features:

  • Managing tasks
  • GUI

Sample code main :

public static void main(String[] args) {
        new Duke().run();
    }

@david-eom david-eom left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! The code looks clean and easy to read, with most of the comments being nit-picky 😂 Think that the logic can be a bit more simplified in Parser, and that some javadoc is missing. Excellent code, keep up the good work!! 👍

Comment on lines +3 to +8
import duke.DukeException;
import duke.Task;
import duke.TaskList;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should java related imports come before duke?

@@ -0,0 +1,42 @@
package duke.Command;

import duke.*;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think perhaps can consider importing individual classes instead of using wildcard import!

Comment on lines +17 to +26
if(type.equals("todo")) {
task = new Task.Todo(description, false);

} else if(type.equals("deadline")) {
String[] temp = description.split("by ", 2);
task = new Task.Deadline(temp[0], false, temp[1]);

} else if(type.equals("event")) {
String[] temp = description.split("at ", 2);
task = new Task.Event(temp[0], false, temp[1]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can consider using enum for this!

Comment thread src/main/java/duke/Storage.java Outdated
* Loads task data from storage
*
* @return ArrayList of tasks
* @throws DukeException

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel like the condition when the DukeException is thrown should be specified here :))

Comment thread src/main/java/duke/Task.java Outdated
this.status= status;
}

public static class Todo extends Task{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a whitespace before the curly braces?

Comment thread src/main/java/duke/Parser.java Outdated
Comment on lines +18 to +54
if (input.equals("bye")) {
return new ExitCommand();
} else if (input.equals("list")) {
return new ListCommand();
} else if (first_word.equals("done")) {
int index;
try {
index = Integer.parseInt(input.split(" ")[1]) - 1;
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException("Sorry, please enter an integer after 'done'. (e.g. done 2)");
}
return new DoneCommand(index);
} else if (first_word.equals("delete")) {
int index;
try {
index = Integer.parseInt(input.split(" ")[1]) - 1;
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException("Sorry, please enter an integer after 'delete'. (e.g. delete 2)");
}
return new DeleteCommand(index);
} else if (first_word.equals("find")){
String remaining;
try {
remaining = input.split(" ", 2)[1];
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException("Sorry, please enter a keyword after 'find'.");
}
return new FindCommand(remaining);
} else {
String remaining;
try {
remaining = input.split(" ", 2)[1];
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException("Sorry, tasks must include descriptions.");
}
return new AddCommand(first_word, remaining);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can use enum here to simplify the logic here! Also, personally I fell that all the try-catch statement here can be abstracted to other class method e.g. createDone() etc. to prevent arrowhead style code, and that one single catch for ArrayIndexOutOfBoundsException could be used for the entire method. Don't know if I articulate my idea in a very accurate way 😂

Comment thread src/main/java/duke/Storage.java Outdated
String line = reader.nextLine();
String[] data = line.split(" \\| ");
switch (data[0]) {
case "todo":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should case be on the same indent level as switch?

@chengseong chengseong left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think the code is very clean and easy to read and there is very clear abstraction between classes. Well done!

@@ -0,0 +1,30 @@
package duke.Command;

import duke.*;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should import package by package, for example import duke.TaskList rather than using import duke.*

Comment thread src/main/java/Command.java Outdated
public abstract class Command {
public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException;

public abstract boolean isExit();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider setting isExit to False in the abstract, then only changing it to True when it is an ExitCommand. This way you do not have to constantly check what Command it is

Gradle run and shadowJar tasks are not functioning as intended.

This should be fixed for ease of use and to create a new JAR release.

Let's edit the build.gradle for proper main class declaration.
Also,let's fix any checkstyle errors that might inhibit the build process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants